/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import db.ConnectionFactory;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 *
 * @author fernandogomespinto
 */
public abstract class Dao <T extends Object> {
    
    // cada Dao terá uma conexão.
    private Connection conexao;

    static {
        try {
            Class.forName( "org.postgresql.Driver" );
            // caso a classe não seja encontrada
        } catch ( ClassNotFoundException exc ) {
            exc.printStackTrace();
        }

    }

    
    public Dao() throws SQLException {
         conexao = ConnectionFactory.getConnection(
                "jdbc:postgresql://localhost:5432/Flex",
                "postgres",
                "123" );
    }
    public Connection getConnection() {
        return conexao;
    }
    
    public void closeConnection() throws SQLException {
        conexao.close();
    }
    public abstract void save( T obj ) throws SQLException;
    
    public abstract void update( T obj ) throws SQLException;
    
    public abstract void delete( T obj ) throws SQLException;
    
    public abstract List<T> listAll() throws SQLException;




    
}
